package com.meteor.downloader.videodownloader.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import coil.load
import coil.transform.RoundedCornersTransformation
import com.meteor.downloader.videodownloader.databinding.ItemFormatItemBinding
import com.meteor.downloader.videodownloader.databinding.ItemHelpItemBinding
import com.meteor.downloader.videodownloader.databinding.ItemLanguageSetItemBinding
import com.meteor.downloader.videodownloader.mdmdata.DataDownloadingMdm
import com.meteor.downloader.videodownloader.mdmdata.DataHelpMdm
import com.meteor.downloader.videodownloader.mdmdata.DataMdmLanguage

class AdapterHelpItem(
    private val mContext: Context,
    private val mListDoData: MutableList<DataHelpMdm>
) :
    RecyclerView.Adapter<AdapterHelpItem.HolderItem>() {
    override fun onCreateViewHolder(
        parent: ViewGroup,
        viewType: Int
    ): HolderItem {
        val binding = ItemHelpItemBinding.inflate(
            LayoutInflater.from(mContext),
            parent,
            false
        )
        val holderItem = HolderItem(binding)
        return holderItem
    }

    override fun onBindViewHolder(
        holder: HolderItem,
        position: Int
    ) {
        val data = mListDoData[position]
        holder.mMdmBinding.apply {
            tvTitleType.text = data.titleType
            tvTitleStep.text = data.titleStep
            tvContentDes.text = data.contentDes
            ivImageStep.load(data.drawableStep){
                transformations(RoundedCornersTransformation())
            }
        }
    }

    override fun getItemCount(): Int {
        return mListDoData.size
    }

    inner class HolderItem(val mMdmBinding: ItemHelpItemBinding) :
        RecyclerView.ViewHolder(mMdmBinding.root)

}